using System.Data;
using System.Collections;
using Microsoft.VisualBasic;
using System.Diagnostics;
using System;

namespace CustomExcelRenderCS
{
    public class RectangleRenderer
    {

        internal RectangleRenderer()
        {
        }
        internal string Render(Microsoft.ReportingServices.ReportRendering.Rectangle rect)
        {
            System.Text.StringBuilder pHtml = new System.Text.StringBuilder();
            pHtml.AppendFormat("<TABLE BORDER=\"0\" CELLSPACING=\"0\" CELLPADDING=\"0\">");
            pHtml.Append("<TR>");
            if (rect.ReportItemCollection == null)
            {
                pHtml.AppendFormat("<TD><DIV STYLE=\"WIDTH:{1}pt;HEIGHT:{0}pt\">", rect.Height.ToPoints().ToString(), rect.Width.ToPoints().ToString());
                pHtml.Append("&nbsp;");
                pHtml.Append("</DIV></TD>");
            }
            else
            {
                for (int i = 0; i <= rect.ReportItemCollection.Count - 1; i++)
                {
                    Microsoft.ReportingServices.ReportRendering.ReportItem rItem = rect.ReportItemCollection[i];
                    string tdDef = Renderer.getTDDef(rItem);
                    pHtml.AppendFormat(tdDef); 
                    pHtml.Append(Renderer.RenderReportItem(rItem));
                    pHtml.Append("</TD>");
                }

            }
            pHtml.Append("</TR>");
            pHtml.Append("</TABLE>\n");

            return pHtml.ToString();
        }
    }

}
